Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Both IndexEntity & RemoveEntity messages are handled #67

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

SebLours
Copy link
Contributor

Fix #66

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 33.33%. Comparing base (adecef0) to head (a7c27df).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/Message/Handler/AbstractEntityHandler.php 0.00% 2 Missing ⚠️
src/Message/Handler/IndexEntityHandler.php 0.00% 2 Missing ⚠️
src/Message/Handler/RemoveEntityHandler.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #67      +/-   ##
============================================
- Coverage     33.36%   33.33%   -0.04%     
- Complexity      648      649       +1     
============================================
  Files           123      123              
  Lines          2161     2163       +2     
============================================
  Hits            721      721              
- Misses         1440     1442       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@loevgaard
Copy link
Member

I propose to not have the __invoke method inside the abstract class and instead move that to the concrete class, so we don't need the handles attribute on the tag.

@SebLours
Copy link
Contributor Author

Ok for this!

@loevgaard
Copy link
Member

will you try and fix it or should I? :)

@SebLours
Copy link
Contributor Author

I try to fix it today!

@loevgaard
Copy link
Member

Great, thanks :D

@SebLours SebLours force-pushed the fix-message-handler branch from 4f7da24 to 68079c6 Compare February 20, 2025 13:49
@SebLours
Copy link
Contributor Author

@loevgaard i add an invoke method in each handler.

I notice another issue (in the master branch) with \Setono\SyliusMeilisearchPlugin\EventListener\Doctrine\EntityListener during the post remove process. I'll have a look later.

@@ -22,7 +22,7 @@ public function __construct(ManagerRegistry $managerRegistry, private readonly I
$this->managerRegistry = $managerRegistry;
}

public function __invoke(RemoveEntity|IndexEntity $message): void
protected function handle(RemoveEntity|IndexEntity $message): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected function handle(RemoveEntity|IndexEntity $message): void
protected function handle(RemoveEntity|IndexEntity $message, callable $action): void

I think I would change the signature to this and add the callback in the concrete handler like:

$this->handle($message, fn(Index $index) => $index->indexer()->removeEntity($entity););

Wdyt?

@SebLours SebLours force-pushed the fix-message-handler branch from 68079c6 to a7c27df Compare February 24, 2025 13:52
@loevgaard
Copy link
Member

Great work, @SebLours 🎉

@loevgaard loevgaard merged commit 0d498fe into Setono:master Feb 24, 2025
33 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Both IndexEntity & RemoveEntity messages are handled
2 participants